package com.leetcode.offer.chapter4;

import com.leetcode.basic.TreeNode;

/**
 * @author Dennis Li
 * @date 2020/7/13 16:20
 */
public class IsSymmetric_28 {

    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;
        return symmetric(root.left, root.right);
    }

    public boolean symmetric(TreeNode t1, TreeNode t2) {
        if (t1 == null && t2 == null) return true;
        if (t1 == null || t2 == null) return false;
        return t1.val == t2.val && symmetric(t1.left, t2.right) && symmetric(t1.right, t2.left);
    }

}
